package com.itheima.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * 切面类1
 *
 * @author liudo
 * @version 1.0
 * @project tlias-backend
 * @date 2023/9/13 11:06:05
 */
@Aspect
// @Component
@Slf4j
public class Aspect2 {
    @Around("com.itheima.aspect.Aspect1.pt()") // 对所有的Service方法进行增强
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {

        log.info("-------Aspect2-----1around 前 通知-------------");
        // 执行Service方法
        Object o = joinPoint.proceed();
        // 打印执行时间
        log.info("--------Aspect2----5around 后 通知-------------");

        return o;
    }
    @Before("execution(* com.itheima.service.*.*(..))")
    public void before(JoinPoint joinPoint) {
        log.info("-----Aspect2-------2before通知-------------");
    }
    @After("execution(* com.itheima.service.*.*(..))")
    public void after(JoinPoint joinPoint) {
        log.info("------Aspect2------4after通知-------------");
    }
    @AfterReturning("execution(* com.itheima.service.*.*(..))")
    public void afterReturning(JoinPoint joinPoint) {
        log.info("----Aspect2--------3AfterReturning通知-------------");
    }
    @AfterThrowing("execution(* com.itheima.service.*.*(..))")
    public void afterThrowing(JoinPoint joinPoint) {
        log.info("------Aspect2------AfterThrowing通知-------------");
    }
}
